package d1023;

public class FunctionDemo03 {
    public static void main(String[] args) {
        Student stu=new Student("迪卢克");
        //Animal ani=new Animal(); 抽象类不能创建对象
        Cat cat=new Cat("迪奥娜");
        //方法的参数是抽象类，传递的应该是该抽象类的子类（具体类）
        stu.feed(cat);
        Dog dog=new Dog("雷泽");
        stu.feed(dog);
        Pig pig=new Pig("猪皮");
        stu.feed(pig);

        stu.feed(new Animal("小白") { // 匿名内部类
            @Override
            public void shout() {
                System.out.println("咯咯咯~~~");
            }
        });

    }
    //内部类
    static class Pig extends Animal{

        public Pig(String name) {
            super(name);
        }

        @Override
        public void shout() {
            System.out.println("哼哼哼");
        }
    }
}

